<template>
  <view>
    <view class="centent">
      <view class="top" @click="showShare" >
        <u-icon name="share-square" color="#fff" size="22"></u-icon>
        <text>分享</text>
      </view>
      <view
        class="bottom"
        @click="backtop"
        :style="{ display: flag === 1 ? 'block' : 'none' }"
      >
        <u-icon name="arrow-upward" color="#fff" size="22"></u-icon>
      </view>
    </view>
    <Share ref="refShare" ></Share>
  </view>
</template>

<script>
import Share from './share.vue'
export default {
  data() {
    return {
      property: "value",
      flag: 0,
    };
  },
  components:{
			Share
		},
  created() {
    this.vm.$on("customEvent", (value) => {
      // 接受自定义事件传递的数据
      this.flag = value;
    });
  },
  methods: {
    backtop() {
      uni.pageScrollTo({
        scrollTop: 0,
      });
    },
    showShare() {
				this.$refs.refShare.handleShowShare();
			},
  },
  destroyed() {
    this.flag = 0;
  },
};
</script>

<style lang="scss" scoped>
.centent {
  position: fixed;
  bottom: 240rpx;
  right: 40rpx;
  border: 1rpx solid #fff;
  padding: 20rpx;
  border-radius: 80rpx;
  background-color: rgba(75, 75, 75, 0.2);
  color: #fff;
  .top {
    padding-bottom: 20rpx;
    font-size: 24rpx;
    text-align: center;
  }
}
</style>